'''
@Descripttion: 
@version: 
@encoding: utf-8
@Author: qiurongcan
Date: 2025-09-09 10:57:27
LastEditTime: 2025-09-09 11:13:32
'''


# 每日最低温度



class Solution:
    def dailyTemperatures(self, temperatures):

        res = [0] * len(temperatures)
        stack = []
        for i, t in enumerate(temperatures):
            while stack and t > temperatures[stack[-1]]:
                temp = stack.pop()
                res[temp] = i - temp

            
            stack.append(i)
            # print(stack)

        return res
    
if __name__ == "__main__":

    tem = [73,74,75,71,69,72,76,73]
    sol = Solution()
    res = sol.dailyTemperatures(tem)
    print(res)


